//
//  OKSickCaseView.m
//  ZLFastDoctor
//
//  Created by answer on 16/5/25.
//  Copyright © 2016年 LS. All rights reserved.
//

#import "OKSickCaseView.h"
#import "OKSickCaseButton.h"
#import "NQRecordManageVc.h"
#import "OKCommitView.h"
#import "OKSickCaseTextView.h"

@interface OKSickCaseView () <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UITextViewDelegate>
@property (weak, nonatomic) IBOutlet OKSickCaseTextView *sickDescView;
@property (weak, nonatomic) IBOutlet OKSickCaseView *sickCaseView;


@end

@implementation OKSickCaseView

- (void)awakeFromNib{
    
    self.sickDescView.delegate = self;
    self.sickDescView.holdString = @"请详细描述您的病情, 病症描述包括患病时间, 症状, 服用药物, 手术或者其他治疗情况请输入\n(100-200)字......";
    
    self.sickCaseView.userInteractionEnabled = YES;
    //给addSickDiscribeView添加手势,用来关闭键盘
    //添加点按手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoard)];
    [self.sickCaseView addGestureRecognizer:tap];
}

- (void)textViewDidChange:(UITextView *)textView {
    if ([textView.text isEqualToString:@""]) {
        self.sickDescView.holdString = @"请详细描述您的病情, 病症描述包括患病时间, 症状, 服用药物, 手术或者其他治疗情况请输入\n(100-200)字......";
        [self.sickDescView setNeedsDisplay];
    } else {
        self.sickDescView.holdString = @"";
        [self.sickDescView setNeedsDisplay];
    }
}

- (void)closeKeyBoard{
    [self endEditing:YES];
}

+ (instancetype)sickCaseView {
    return [[[NSBundle mainBundle] loadNibNamed:@"OKSickCaseView" owner:nil options:nil] lastObject];
}

- (IBAction)btnClickAction:(OKSickCaseButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        [sender setTitleColor:[UIColor colorWithRed:50/255.0 green:190/255.0 blue:190/255.0 alpha:1.0] forState:UIControlStateSelected];
        sender.layer.borderColor = [UIColor colorWithRed:50/255.0 green:190/255.0 blue:190/255.0 alpha:1.0].CGColor;
    } else {
        [sender setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        sender.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
}

// 选择已有病例
- (IBAction)pushToSickList:(UIButton *)sender {
    
    self.callBack();
    
}

// 添加病例图片
- (IBAction)addPicture:(id)sender {
    
    if ([self.delegate respondsToSelector:@selector(btnAddImageCallBack:)]) {
        [self.delegate btnAddImageCallBack:sender];
    }

}


@end








